﻿@model IEnumerable<PlaceSystem.Areas.Admin.Models.UserViewModel>

@{
    ViewBag.Title = "Index";
}


<h2>Index</h2>

<div class="hero-unit">
    <h2>Users</h2>

    @(Html
    .Kendo().Grid(Model)
    .Name("users-grid")
    .Columns(columns =>
            {
                columns.Bound(u => u.Username);
                columns.Bound(u => u.Role);
                columns.Bound(u => u.FavoriteCount);
                columns.Bound(u => u.CommentsNumber);
                columns.Template(@<text>
                    @Html.ActionLink("Edit", "Edit", new { id = item.Id })
                </text>);
                @*columns.Template(@<text>
            @Html.ActionLink("Delete", "Delete", new { id = item.Id })
                </text>);*@
            })
                                    .Sortable(sort =>
                                            {
                                                sort.AllowUnsort(false);
                                                sort.SortMode(GridSortMode.SingleColumn);
                                            })
                                    .Pageable()
                                    .Filterable()
                                    .DataSource(dataSource => dataSource
                                        .Server()
                                        .Read(read => read.Action("Index", "User"))
                                    .PageSize(5)))
</div>

<div>
    @Html.ActionLink("Back to main administration page", "Index", "Main")
</div>



@*
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Role)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Username)
              </th>
            <th>
                @Html.DisplayNameFor(model => model.CommentsNumber)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.FavoriteCount)
            </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Role)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Username)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CommentsNumber)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FavoriteCount)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
                @Html.ActionLink("Details", "Details", new { id=item.Id }) |
                @Html.ActionLink("Delete", "Delete", new { id=item.Id })
            </td>
        </tr>
    }

    </table>*@